<template>
  <div>
    <el-row>
      <el-col :span="24" align="right">
        <div style="margin-top:10px">
          <el-input style="width:200px" v-model="filters.key" placeholder="请输入信息"></el-input>
          <el-button type="primary" icon="search" @click="getUserInfo">搜索</el-button>
          <el-button type="primary" @click="flushAll">刷新</el-button>
        </div>
        <el-row style="margin-top:20px">
          <el-col :span="24">
            <el-table border  :data="list">
              <el-table-column type="index" width="90" align="center"></el-table-column>
              <el-table-column v-for="(v,k,i) in props" :key="i" :label="labels[i]" align="center">
                <template scope="scope">
                  {{scope.row[k]}}
                </template>
              </el-table-column>
              <el-table-column label="操作" width="200" align="center">
                <template scope="scope">
                  <el-button size="mini" @click="update(1,scope.row.userID)" type="success" >审核通过</el-button>
                  <el-button size="mini" @click="update(0,scope.row.userID)" type="danger">审核不通过</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-col>
          <el-col :span="24" style="margin-top:10px" align="right">
            <el-pagination layout="prev, pager, next" :total="totalInfo" @current-change="handleCurrentChange">
            </el-pagination>
          </el-col>
        </el-row>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import * as api from "@/api/systemManage";
import * as api2 from "@/api/zonghezhili/duiwujianshe";
export default {
  data() {
    return {
      visible: false,
      visible2: false,
      filters: {
        key: null,
        page: 1,
        pageSize: 10
      },
      editPassWord: null,
      list: [],
      totalInfo: 0,
      item: {
        userName: "",
        password: "",
        realName: "",
        netGridID: "",
        roleID: "",
        certID: "",
        mobileTel: "",
        dept: ""
      },
      editUser: {},
      NetGrid: [],
      AllRole: [],
      props: {
        userName: "",
        realName: "",
        certID: "",
        mobileTel: "",
        userRole: "",
        dept: ""
      },
      labels: ["用户名", "真实姓名", "身份证", "手机号", "角色", "所属部门"],
      rules: {
        userName: [
          { required: true, message: "请输入用户名", trigger: "blur" }
        ],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }]
      },
      rules2: {
        userName: [{ required: true, message: "请输入用户名", trigger: "blur" }]
      }
    };
  },
  methods: {
    async update(status,id) {
      this.$confirm('是否确认更新该账号审核状态？', '是否继续', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        let res = await api.checkUser({status,id});
        if(res.data == true){
          this.getUserInfo();
        }
      }).catch(() => {

      });
    },
    reset() {
      for (var key in this.item) {
        this.item[key] = "";
      }
    },
    closeDialog(){
      this.editPassWord = null
    },
    flushAll() {
      this.filters.key = null;
      this.getUserInfo();
    },
    handleCurrentChange(val) {
      this.filters.page = val;
      this.getUserInfo();
    },
    getUserInfo() {
      api.getCheckUserInfo(this.filters).then(res => {
        this.list = res.data.list;
        this.totalInfo = res.data.total;
      });
    }
  },
  mounted() {
    this.getUserInfo();
  }
};
</script>


<style scoped>

</style>
